<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Person (name, price) {
            this.name = name
            this.price = price 
        }
        Person.prototype.getPersonName = function () {
            console.log(this.name)
        }

        Student.prototype = new Person()
        Student.prototype.constructor = Student

        function Student (name, price) {
            // call方法可以调用函数
            Person.call(this, name, price)
        }
        Student.prototype.getStudentName = function () {
            console.log(this.name)
        }
        
        const student = new Student('xiaomi', 12000)
        console.log(student.name)
        student.getStudentName()
        student.getPersonName()
    </script>
</body>
</html>